/*package itcast.bos.base.test;

import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageListener;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.junit.Test;

public class ActiveMqCustomer_Demo2 {
	public static void main(String[] args) throws Exception {
		// 新建一个链接工厂
		ConnectionFactory cf = new ActiveMQConnectionFactory();
		// 获取一个链接
		Connection connection = cf.createConnection();
		// 开启链接
		connection.start();
		// 建立回话
		Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
		// 创建队列或话题对象
		Queue queue = session.createQueue("Hello Mamba");
		// 创建消费者
		MessageConsumer c = session.createConsumer(queue);

		// 接受消息
		while (true) {
			// 获取信息
			TextMessage m = (TextMessage) c.receive(10000);
			if (m != null) {
				System.out.println(m);
			} else {
				break;
			}

		}
	}

	
	////@Test
	private static void testmothed1() throws JMSException {
		// 新建一个链接工厂
		ConnectionFactory cf = new ActiveMQConnectionFactory();
		// 获取一个链接
		Connection connection = cf.createConnection();
		// 开启链接
		connection.start();
		// 建立回话
		Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
		// 创建队列或话题对象
		Queue queue = session.createQueue("Hello Mamba");
		// 创建消费者
		MessageConsumer c = session.createConsumer(queue);
		
		c.setMessageListener(new MessageListener() {

			@Override
			public void onMessage(Message m) {
				TextMessage m2 = (TextMessage) m;
				while (true) {
					try {
						System.out.println(m2.getText());
					} catch (JMSException e) {
						e.printStackTrace();
					}
				}
			}
		});
		while(true){
			
		}
	}
}
*/